def fun():
    fr = open("sensor.txt","r",encoding ="utf-8");
    fw = open("arpa001.txt","w");
    for i in fr:
        ls = i.strip("\n").split(',');
        if " arpa001" in ls:
            fw.write("{},{},{},{}\n".format(ls[0],ls[1],ls[2],ls[3]));
    fw.close();
    fr.close();
fun();

def fun2():
    d = {};
    fr2 = open("arpa001.txt","r");
    fw2 = open("arpa001_count.txt","w");
    for line in fr2:
        temp = line.strip("\n").split(",");
        s = temp[2] + "-" + temp[3];
        d[s] = d.get(s,0) + 1;
    ls = list(d.items());
    for i in ls:
        fw2.write("{},{}\n".format(i[0],i[1]));
    fw2.close();
    fr2.close();
fun2();
    
